/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { isLegalData } from '@/utils/utils';
import { message } from 'antd';
import request from '../utils/request';

// 获取巴枪扫描配置列表
export async function getPostList(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/queryCompanyInfo', {
    method: 'POST',
    body: params,
  });
}
// 删除单条巴枪扫描配置
export async function deleteOption(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/deleteCompanyInfo', {
    method: 'POST',
    body: params,
  });
}
// 开启/关闭服务
export async function openService(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/disabledCompanyInfo', {
    method: 'POST',
    body: params,
  });
}
// 修改扫描配置
export async function setScanOption(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/scanConfig', {
    method: 'POST',
    body: params,
  });
}
// 新增单条快递公司信息
export async function addOption(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/addCompanyInfo', {
    method: 'POST',
    body: params,
  });
}
// 修改单条快递公司信息
export async function correctOption(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/amendCompanyInfo', {
    method: 'POST',
    body: params,
  });
}
// 获得到件扫描记录的搜索列表
export async function getScanSearch(params) {
  return request('/v1/TotalDistribution/MultiBrandQueryInfo/getScanRecord', {
    method: 'POST',
    body: params,
  });
}
// 获取网点信息
export async function getBranchInfo(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/getBranchInfo', {
    method: 'POST',
    body: params,
    nonceKey: 'branch_id,area_id',
  });
}
// 获取总览数据
export async function getAllView(params) {
  return request('/v1/TotalDistribution/MultiBrandQueryInfo/getSumTotal', {
    method: 'POST',
    body: params,
  });
}
// 获取近30天数据趋势
export async function getChartsView(params) {
  return request('/v1/TotalDistribution/MultiBrandQueryInfo/getMultiBrandTrend', {
    method: 'POST',
    body: params,
  });
}
// 获取近30天数据趋势
export async function getCode(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/sendVerifyCode', {
    method: 'POST',
    body: params,
  });
}
// 获取下一站设置列表
export async function getSetList(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/nextList', {
    method: 'POST',
    body: params,
  });
}
// 下一站设置列表，删除
export async function deletSetList(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/nextDelete', {
    method: 'POST',
    body: params,
  });
}
// 下一站设置列表，添加
export async function addSetList(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/nextConfig', {
    method: 'POST',
    body: params,
  });
}
// 获取业务员看板Tabs列表
export async function getTabList(params) {
  return request('/v1/TotalDistribution/CourierBulletinBoard/getAllBrand', {
    method: 'POST',
    body: params,
  });
}
// 获取业务员看板table数据
export async function getKanBanList(params) {
  return request('/v1/TotalDistribution/CourierBulletinBoard/getBulletinBoard', {
    method: 'POST',
    body: params,
  });
}
// 获取业务员看板下拉框数据
export async function getKanBanOperatorList(params) {
  return request('/v1/TotalDistribution/kanban/searchOperator', {
    method: 'POST',
    body: params,
  });
}
// 获取业务员看板下拉框数据
export async function kanBanResend(params) {
  return request('/v1/TotalDistribution/CourierBulletinBoard/reUploadFail', {
    method: 'POST',
    body: params,
  });
}
// 巴枪设备编号，获取上一站信息及巴枪设备编号
export async function getCompanyInfoByBranchCode(params) {
  return request('/Api/Company/getCompanyInfoByBranchCode', {
    method: 'POST',
    body: params,
  });
}
// 巴枪注册，获取巴枪注册列表
export async function getDeviceNumberList(params) {
  return request('/Api/DeviceNumber/getDeviceNumberList', {
    method: 'POST',
    body: params,
  });
}
// 巴枪设备编号，中通，中通获取巴枪设备列表
export async function getDeviceNumberListForZt(params) {
  return request('/Api/DeviceNumber/getDeviceNumberListForZt', {
    method: 'POST',
    body: params,
  });
}
// 巴枪注册，发起巴枪注册
export async function saveDeviceNumber(params) {
  return request('/Api/DeviceNumber/saveDeviceNumber', {
    method: 'POST',
    body: params,
  });
}
// 巴枪设备编号，中通添加巴枪设备编号
export async function saveDeviceNumberForZt(params) {
  return request('/Api/DeviceNumber/saveDeviceNumberForZt', {
    method: 'POST',
    body: params,
  });
}
// 巴枪注册，删除未通过或通过的审核记录
export async function deleteDeviceNumber(params) {
  return request('/Api/DeviceNumber/deleteDeviceNumber', {
    method: 'POST',
    body: params,
  });
}
// 巴枪设备编号，中通删除未通过或通过的审核记录
export async function deleteDeviceNumberForZt(params) {
  return request('/Api/DeviceNumber/deleteDeviceNumberForZt', {
    method: 'POST',
    body: params,
  });
}
// 巴枪注册，获取工号下拉信息
export async function getRegisterCodeInfoList(params) {
  return request('/Api/Courier/getZtoCourierInfo', {
    method: 'POST',
    body: params,
  });
}
// 申通获取巴枪型号
export async function getGunType(params) {
  return request('/Api/PdaDevice/getPdaDeviceList', {
    method: 'POST',
    body: params,
  });
}
// 巴枪扫描，扣费设置
export async function getUserInfo(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/getUserInfo', {
    method: 'POST',
    body: params,
  });
}
// 巴枪扫描，扣费设置
export async function deduction(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/editDeductionType', {
    method: 'POST',
    body: params,
  });
}
// 巴枪扫描，校验申通工号
export async function checkStoGunAccount(params) {
  return request('/v1/TotalDistribution/GunInformation/checkStoCmInfo', {
    method: 'POST',
    body: params,
  });
}
// 巴枪扫描，扣费设置，获取短信验证码
export async function getShortMessage(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/sendVerifyCodeForGunSet', {
    method: 'POST',
    body: params,
  });
}
// 巴枪扫描，扣费设置，验证短信
export async function stoCheckPhone(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/stoVerifyForGunSet', {
    method: 'POST',
    body: params,
  });
}
// 共配权限管理，获取列表
export async function getAuthManagementList(params) {
  return request('/Api/ChinaPost/ZyGpJur/getListBySearch', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，扫描记录列表接口
export async function getScanRecordsList(params) {
  return request('/v1/TotalDistribution/CustomScan/getScanRecord', {
    method: 'POST',
    body: params,
  });
}
// 共配权限管理，修改共配权限
export async function changeAuth(params) {
  return request('/Api/ChinaPost/ZyGpJur/modifyGp', {
    method: 'POST',
    body: params,
  });
}
// 共配权限管理，获取不同品牌的共配权限
export async function getGpAuthListByBrand(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/getScanPower', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，扫描类型列表接口
export async function getScanTypesList(params) {
  return request('/v1/TotalDistribution/CustomScan/getScanTypeList', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，添加扫描类型
export async function addScanType(params) {
  return request('/v1/TotalDistribution/CustomScan/newBuildScanType', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，删除扫描类型
export async function deleteScanType(params) {
  return request('/v1/TotalDistribution/CustomScan/editScanType', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，扫描类型下拉接口
export async function getScanOptionList(params) {
  return request('/v1/TotalDistribution/CustomScan/getScanOptionList', {
    method: 'POST',
    body: params,
  });
}
// 共配，自定义扫描，扫描纪录，获取网点编号
export async function getScanType(params) {
  return request('/v1/TotalDistribution/CustomScan/getScanType', {
    method: 'POST',
    body: params,
  });
}
// 共配，密钥配置，获取列表
export async function getPrintKeyList(params) {
  return request('/Api/Agent/getAgentList', {
    method: 'POST',
    body: params,
  });
}
// 共配，密钥配置，添加密钥
export async function addPrintKey(params) {
  return request('/Api/Agent/addAgent', {
    method: 'POST',
    body: params,
  });
}
// 共配，密钥配置，删除密钥
export async function deletePrintKey(params) {
  return request('/Api/Agent/delAgent', {
    method: 'POST',
    body: params,
  });
}
// 共配，密钥配置，刷新状态
export async function refreshStatus(params) {
  return request('/Api/Agent/editAgentStatus', {
    method: 'POST',
    body: params,
  });
}
// 共配，数据统计，获取扫描统计列表
export async function getScanList(params) {
  return request('/v1/TotalDistribution/MultiBrandQueryInfo/getSumTotalByCourier', {
    method: 'POST',
    body: params,
  });
}
// 共配，数据统计，获取派件统计列表
export async function getSendList(params) {
  return request('/v1/TotalDistribution/MultiBrandQueryInfo/getSumTotalByOperator', {
    method: 'POST',
    body: params,
  });
}
// 巴枪设备编号，圆通添加巴枪设备编号
export async function saveDeviceNumberForYt(params) {
  return request('/Api/DeviceNumber/saveDeviceNumberForYt', {
    method: 'POST',
    body: params,
  });
}
// 共配，数据监控，扫描识别记录、特殊件操作记录列表
export async function getMonitorList(params) {
  return request('/v1/TotalDistribution/OperationRecord/getOperationRecord', {
    method: 'POST',
    body: params,
  });
}
// 共配，数据监控，获取所有类型
export async function getAllMonitorType(params) {
  return request('/v1/TotalDistribution/OperationRecord/getAllType', {
    method: 'POST',
    body: params,
  });
}
// 共配，数据监控，获取所有支持的品牌
export async function getAllMonitorBrand(params) {
  return request('/v1/TotalDistribution/OperationRecord/getAllBrand', {
    method: 'POST',
    body: params,
  });
}

export async function getJtTaskNumber(params) {
  return request('/Api/Company/getJtNo', {
    method: 'POST',
    body: params,
  });
}
export async function setJtTaskNumber(params) {
  return request('/Api/Company/setJtNo', {
    method: 'POST',
    body: params,
  });
}
/** 发派设置列表 */
export async function getSendSetting(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/getSenderByKbId', {
    method: 'POST',
    body: params,
  }).then(res => {
    const { code, data = {}, msg } = res;
    if (code != 0) {
      message.error(msg);
    }
    return {
      list: Object.keys(isLegalData(data, {})).length > 0 ? [data] : [],
      pagination: null,
    };
  });
}
/** 发派设置，获取发件扫描业务员 */
export async function getCourierInfo(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/getCourierListByShopId', {
    method: 'POST',
    body: params,
  }).then(res => {
    const { code, data, msg } = res;
    if (code != 0) {
      message.error(msg);
    }
    return isLegalData(data);
  });
}
/** 发派设置，添加发件扫描业务员 */
export async function addCourierInfo(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/addSender', {
    method: 'POST',
    body: params,
  });
}
/** 发派设置，删除发件扫描业务员 */
export async function deleteCourierInfo(params) {
  return request('/v1/TotalDistribution/ExpressCompanyInfo/delSender', {
    method: 'POST',
    body: params,
  });
}
/** 共配同意授权 */
export async function confirmGpAuth(params) {
  return request('/Api/Company/editDisclaimerStatus', {
    method: 'POST',
    body: params,
  });
}
